   NS4 = (document.layers);
   IE4 = (document.all);
  ver4 = (NS4 || IE4);
   IE5 = (IE4 && navigator.appVersion.indexOf("5.")!=-1);
 isMac = (navigator.appVersion.indexOf("Mac") != -1);
isMenu = (NS4 || (IE4 && !isMac) || (IE5 && isMac));

var lang = GetCookie("g_language");
if (!lang) lang="zh-tw";
document.write("<script language=\"javascript\" src=\"lang/" + lang + ".js\"></script>");

if (location.search!="?op=core&fp=cookie") {
	if (GetCookie("PHPSESSID")==null) {
		location.href="?op=core&fp=cookie";
	}
}

//addy
function MM_preload() { 
    var d = document;
    if (!d.MM_p) d.MM_p = new Array();
    var i, j=d.MM_p.length, a=MM_preload.arguments;
    for(i=0; i<a.length; i++) {
        if (a[i].indexOf("#")!=0) {
            d.MM_p[j]=new Image;
            d.MM_p[j++].src=a[i];
        }
    }
}
//addy 2012-03-23 ÀË¬d¹L¥¼¨Ï¥Î¦bµ{§Ç¤º
function isIDnum(num){
   num=num.toLowerCase()
   
   patten=/^[a-z][12][0-9]{8}$/
   if(patten.test(num)){
      h="abcdefghjklmnpqrstuvxywzio"
      x=10+h.indexOf(num.substring(0,1))
      chksum=(x-(x%10))/10+(x%10)*9
      for(i=1;i<9;i++){
         chksum+=num.substring(i,i+1)*(9-i)
      } 
      chksum=(10-chksum%10)%10 
      
      if(chksum==num.substring(9,10))return true
   }
   return false
}

//addy
function RClock()
{
	if (isNaN(RSecond) || RSecond.length == 0) return;
	if (RSecond == 0) {
		
		document.location.href = document.location.href;
		return;
	}
	RSecond--;
	document.getElementById("pclock").innerHTML = (RSecond < 10) ? "0" + RSecond : RSecond;
	setTimeout("RClock()",1000);
}


function RClockRate()
{
	if (isNaN(RSecond) || RSecond.length == 0) return;
	RSecond--;
	if (RSecond == 0) {
		location.replace("?op=member&fp=account");
	}
	document.getElementById("pclock").innerHTML = (RSecond < 10) ? "0" + RSecond : RSecond;
	setTimeout("RClockRate()",1000);
}

//addy
function MyClock()
{
	if (!vMyclock) return;
	var d = new Date();
	d.setTime(vMyclock);
	vMyclock+=500;
	
	var s = d.getHours()+":"+d2(d.getMinutes())+":"+d2(d.getSeconds());
	
	if (NS4){
		Ypos=window.pageYOffset+window.innerHeight-60;
		Xpos=window.pageXOffset+window.innerWidth-80;
	} else {
		Ypos=document.body.scrollTop+window.document.body.clientHeight-20;
		Xpos=document.body.scrollLeft+window.document.body.clientWidth-60;
	}
	idMyClock.innerHTML = s;
	idMyClock.style.pixelTop = Ypos;
	idMyClock.style.pixelLeft = Xpos;
	setTimeout("MyClock()",500);
}


function d2(d)
{
	if (d<10) return "0"+d;
	return d;
}

function msover()
{
	var e = event.srcElement;
	while (e.tagName!="TR") e = e.parentElement;
	e.style.backgroundColor = "#FFFFCC";
}
function msout()
{
	var e = event.srcElement;
	while (e.tagName!="TR") e = e.parentElement;
	e.style.backgroundColor = "";
}

function KeyNumber()
{
	if (event.keyCode == 13) return true;
	if ((event.keyCode < 48 || event.keyCode > 57) && (event.keyCode > 95 || event.keyCode < 106)) return false;
}

function CheckAccountKey()
{
	var key = event.keyCode;
	if ((key >= 97 && key <=122) || (key >= 65 && key <=90) || (key >= 48 && key <=57))
		return true;
	return false;
}

//addy
function OnlyNumberKey()
{
	var key = event.keyCode;
	if (key==13) return true;
	if (key==46) return true;
	if (key >= 48 && key <=57) return true;
	return false;
}


function OnlyInt()
{
	var key = event.keyCode;
	if (key==13) return true;
	if (key >= 48 && key <=57) return true;
	return false;
}

//addy
function OnlySignInt()
{
	var key = event.keyCode;
	if (key==13) return true;
	if (key >= 48 && key <=57) return true;
	if (key ==45) return true; 
	return false;
}


function OnlyFloat()
{
	var key = event.keyCode;
	if (key==13) return true;
	if (key==46) return true;
	if (key >= 48 && key <=57) return true;
	return false;
}

function GetCookie (name) {
	var arg = name + "=";
	var alen = arg.length;
	var clen = document.cookie.length;
	var i = 0;
	while (i < clen) {
		var j = i + alen;
		if (document.cookie.substring(i, j) == arg) {
			var endstr = document.cookie.indexOf(";", j);
			if (endstr == -1) endstr = document.cookie.length;
			return unescape(document.cookie.substring(j, endstr));
		}
		i = document.cookie.indexOf(" ", i) + 1;
		if (i == 0) break;
	} return null;
}

function SetCookie (name, value) {
	var argv = SetCookie.arguments;
    var argc = SetCookie.arguments.length;
    var expires = (argc > 2) ? argv[2] : null;
    var path = (argc > 3) ? argv[3] : null;
    var domain = (argc > 4) ? argv[4] : null;
    var secure = (argc > 5) ? argv[5] : false;
    document.cookie = name + "=" + escape (value) +
    	((expires == null) ? "" : ("; expires=" + expires.toGMTString())) +
    	((path == null) ? "" : ("; path=" + path)) +
      	((domain == null) ? "" : ("; domain=" + domain)) + ((secure == true) ? "; secure" : "");
}
//addy
function DeleteCookie (name) {
	var exp = new Date();
	exp.setTime(exp.getTime() - 1); 
	document.cookie = name + "=" + cval + "; expires=" + exp.toGMTString();
}

//addy
function printpage()
{
	if (window.print) {
		window.print();
	} else {
		alert('No printer driver in your PC');
	}
}

function n2c(number)
{
	if ((GetCookie("g_language")!="zh-tw") && (GetCookie("g_language")!="zh-cn")) return "";
	
    var buffer, len, time, m, n, foo, first
    buffer = "";
	if (number.length>4) {
        len  = number.length;
        time = (len%4!=0)?parseInt(len/4)+1:(len/4);
        for(n=1,m=4;n<=time;n++) {
			if(n==time) {
				if (len%4>0)
					foo = n2c(number.substr(0,len % 4));
				else
					foo = n2c(number.substr(len - m,4));
            } else foo = n2c(number.substr(len - m,4));
            if(foo) buffer = foo + sOrder[n] + buffer;
            m = m + 4;
        }
        var reg1 = new RegExp("^"+sChinese[0],"ig");
        var reg2 = new RegExp("(^["+sChinese[0]+"]{1,})([^"+sChinese[0]+"]{0,})","ig");
        if(reg1.test(buffer)) buffer = buffer.replace(reg2, "$2");
        return buffer;
    } else {
    	
        if(number.length==0 || !(/[1-9]/ig).test(number)) return "";
        first = number.substr(0,1);
        
        buffer += sChinese[first];

        if(first!=0) buffer += sLength[number.length];
        
        if ((/^0/ig).test(number)) buffer += n2c(number.replace(/(^0+)([1-9]*)/ig,"$2"));
        else  buffer += n2c(number.substr(1));
        return buffer;
    }
}

//addy
function colornumber(num)
{
	var s = ""+num;
	if (s.length>4) {
		s = "<font color=#FF5500>" + s.substr(0, s.length-4) + "</font>" + s.substr(s.length-4);
	}
	return s;
}

function trim(s)
{
	return s.replace(/^[\s]+/g,"").replace(/[\s]+$/g,"");
}

//addy
function initarray(count, def)
{
	for (var i=0; i<count; i++)
		this[i] = def;
	return this;
}
	
//addy
function push(ary, value)
{
	var i;
	for (i=ary.length-1; i>0; i--) ary[i] = ary[i-1];
	ary[0] = value;
}

//addy
function popup(url,target,width,height)
{
	if (!target) target = "_self";
	if (!width) width = 500;
	if (!height) height = 500;
	var w = window.open(url, target, "menu=0,width=" + width + ",height=" + height + ",resizable=1,scrollbars=1");
	w.focus();
	return w;
}
    